package midway.madness;

import java.util.List;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CategoryListAdapter extends ArrayAdapter<CategoryObject>{
	private List<CategoryObject> catObjs;

	public CategoryListAdapter(Context context,	int textViewResourceId, List<CategoryObject> objects) {
		super(context, textViewResourceId, objects);
		catObjs = objects;
	}
	
	public View getView(int position, View convertView, ViewGroup parent){
		View retView = convertView;
		if (null == retView){
			LayoutInflater lf = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			retView = lf.inflate(R.layout.category_info_view, null);
		}
		CategoryObject cat = catObjs.get(position);
		if (null != cat){
			TextView category = (TextView) retView.findViewById(R.id.category_title_text);
			
			if (null != category){
				category.setText(Html.fromHtml(cat.getName()));
			}
		}
		return retView;
	}
}
